package com.lzh.shijicloudstack.common;

import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * @author luzhiheng
 * @date 2023-11-23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@MappedSuperclass
public class BaseEntity implements Serializable {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Id
    @Column(name = "id", columnDefinition = "bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID'", nullable = false)
    private Long id;

    /**
     * 创建时间
     */
    @Column(name = "create_time", columnDefinition = "datetime COMMENT '创建时间'")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time", columnDefinition = "datetime COMMENT '更新时间'")
    @TableField(fill = FieldFill.UPDATE)
    private Date updateTime;

    /**
     * 删除时间
     */
    @Column(name = "delete_time", columnDefinition = "datetime COMMENT '删除时间'")
    @TableField(fill = FieldFill.UPDATE)
    private Date deleteTime;

    /**
     * 创建人
     */
    @Column(name = "create_name", columnDefinition = "varchar(255) COMMENT '创建人名称'")
    @TableField(fill = FieldFill.INSERT)
    private String createName;

    /**
     * 创建人ID
     */
    @Column(name = "create_user_id", columnDefinition = "varchar(255) COMMENT '创建人ID'")
    @TableField(fill = FieldFill.INSERT)
    private String createUserId;

    /**
     * 更新人
     */
    @Column(name = "update_name", columnDefinition = "varchar(255) COMMENT '更新人名称'")
    @TableField(fill = FieldFill.UPDATE)
    private String updateName;

    /**
     * 更新人ID
     */
    @Column(name = "update_user_id", columnDefinition = "varchar(255) COMMENT '更新人ID'")
    @TableField(fill = FieldFill.UPDATE)
    private String updateUserId;

    /**
     * 删除人
     */
    @Column(name = "delete_name", columnDefinition = "varchar(255) COMMENT '删除人名称'")
    @TableField(fill = FieldFill.UPDATE)
    private String deleteName;

    /**
     * 删除人ID
     */
    @Column(name = "delete_user_id", columnDefinition = "varchar(255) COMMENT '删除人ID'")
    @TableField(fill = FieldFill.UPDATE)
    private String deleteUserId;

    /**
     * 逻辑删除（1代表未删除，0代表已删除）
     */
    @Column(name = "open_flag", columnDefinition = "tinyint DEFAULT '1' COMMENT '逻辑删除（1代表未删除，0代表已删除）'")
    @TableLogic
    private Integer openFlag = 1;
}
